<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="language" content="en" />
        <?php
        $id = $_GET['id'];
        $shopcode = 'shop' . $id;
        if (isset(Yii::app()->request->cookies[$shopcode]->value)) {
            $shop = Yii::app()->request->cookies[$shopcode]->value;
        } else {
            $shoplist = Shop::model()->findAll(' `flag`=1 and `shopCode`="' . $id . '"');

            if (!empty($shoplist)) {
                foreach ($shoplist as $s) {
                    $idshop = $s->id;
                    $shopName = $s->shopName;
                    $shopCode = $s->shopCode;
                }

                $config = ShopConfig::model()->findAll(' `shoid`=' . $idshop);
                if (!empty($config)) {
                    foreach ($config as $c) {
                        $shopshop = array($idshop, $shopName, $shopCode, $c->logo, $c->url_logo, $c->footer, $c->address, $c->phone, $c->metakeyword, $c->metadisception, $c->yotube,$c->facebook,$c->google,$c->twitter);
                    }
                    $json = json_encode($shopshop, true);

                    $cookie = new CHttpCookie($shopcode, $json);

                    $cookie->expire = time() + 60 * 60 * 24;
                    Yii::app()->request->cookies[$shopcode] = $cookie;
                } else {
                    $this->redirect('http://salesmartlink.com');
                }
            } else {
                $this->redirect('http://salesmartlink.com');
            }
        }
        $shoparry = Yii::app()->request->cookies[$shopcode]->value;
        //$shopary = stripslashes($shoparry); dong nay bo dau tieng viet
        $savedCardArray = json_decode($shoparry, true);
        ?>

        <meta name="keywords" content="<?php echo $savedCardArray[8]; ?>" />
        <meta name="description" content="<?php echo $savedCardArray[9]; ?> " />
        <title><?php echo $savedCardArray[1]; ?></title>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/css.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/cssmenu.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/buttons.css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/pager.css" />
        <link href="<?php echo Yii::app()->request->baseUrl; ?>/css/home/menuV2.css" rel="stylesheet" type="text/css" />
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/jsImgSlider/themes/6/js-image-slider.css" />
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jsImgSlider/themes/6/mcVideoPlugin_1.js" type="text/javascript"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/jsImgSlider/themes/6/js-image-slider_1.js" type="text/javascript"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/home/menuV2.js" type="text/javascript"></script>
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/home/jquery.countdown.js" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/skins/tango/skin.css" />

        <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/productslider/jquery.jcarousel.min.js"></script>


        <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.msgBox/Scripts/jquery.msgBox.js"></script>
        <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery.msgBox/Styles/msgBoxLight.css" />
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <script src="<?php echo Yii::app()->request->baseUrl; ?>/js/ui/jquery-ui.js"></script>
        <script type="text/javascript">
                     $(document).ready(function() {
                var $winwidth = $(window).width();
                var el = document.getElementById('nd');
                var h = document.getElementById('head');
                var b = document.getElementById('col');
                     if ($winwidth > 1349) {
                        el.style.width = $winwidth;
                        h.style.width = $winwidth;
                        b.style.width = $winwidth - 390;
                    } else {
                        el.style.width = "1349px";
                        h.style.width = "1349px";
                        b.style.width = "968px";
                    }


           
            
                $(window).bind("resize", function() {
                    var $winwidth = $(window).width();
                    var el = document.getElementById('nd');
                    var h = document.getElementById('head');
                     var b = document.getElementById('col');
                    if ($winwidth > 1349) {
                        el.style.width = $winwidth;
                        h.style.width = $winwidth;
                        b.style.width = $winwidth - 390;
                    } else {
                        el.style.width = "1349px";
                        h.style.width = "1349px";
                        b.style.width = "968px";
                    }
                });
            });

        </script>
    </head>
    <body>


         <?php
        $baner = Panel::model()->findAll(
                array(
                    'condition' => ' `flag`=1 and `type`=0 and `dateCreate`<= CURDATE() and `dateEpend`>=CURDATE() order by vitri ASC',
                    'limit' => 30,
                )
        );
        if (!empty($baner)) {
            $lan = 0;
            $right = '';
            $flag = 0;
            $dem = 0;
            $dem1 = 0;
            $left = '';
            foreach ($baner as $b) {

                $h = 0;

                $lan = $lan + 1;

                if ($lan < 2) {
                    if ($b->kieu == 0) {
                        $h = 396;
                    } elseif ($b->kieu == 1) {
                        $h = 792;
                        $flag = 1;
                    }
                    $left = $left . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                } elseif ($lan < 3) {
                    if ($flag < 1) {
                        $left = $left . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="396"  border="0"></a>';
                    } else {
                        $flag = 2;
                        if ($b->kieu == 0) {
                            $dem = $dem + 1;
                            $h = 264;
                            if ($dem < 2) {
                                $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                            } elseif ($dem < 3) {
                                $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                            } elseif ($dem > 2) {
                                $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                                $dem = 0;
                            }
                        } elseif ($b->kieu == 2) {

                            $h = 264 + 266;
                            if ($dem == 1) {
                                $dem = 0;
                                $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                            } else {
                                $dem = 3;
                                $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                            }
                        } elseif ($b->kieu == 3) {
                            $h = 792;
                            $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                        }
                    }
                } else {
                    $flag = 2;
                    if ($b->kieu == 0) {
                        $dem = $dem + 1;
                        $h = 264;
                        if ($dem < 2) {
                            $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                        } elseif ($dem < 3) {
                            $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                        } elseif ($dem > 2) {
                            $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                            $dem = 0;
                        }
                    } elseif ($b->kieu == 2) {

                        $h = 264 + 266;
                        if ($dem == 1) {
                            $dem = 0;
                            $right = $right . '<a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                        } else {
                            $dem = 3;
                            $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a>';
                        }
                    } elseif ($b->kieu == 3) {
                        $h = 792;
                        $right = $right . '<li><a href="' . $b->url . '" target="_blank" rel="nofollow"><img class="aut" title="' . $b->name . '" src="' . Yii::app()->request->baseUrl . '/upload/quangcao/' . $b->photo . '" width="180" height="' . $h . '"  border="0"></a></li>';
                    }
                }
            }
        }
        ?>
        <?php
        $this->renderPartial('//shop/layouts/header');
        ?>


        <div id="nd" style="padding-top: 64px;" >


            <div class="Colum1">
                <?php echo $left; ?>
            </div>
            <div id="col" style="float: left;">
                <div class="noidungfix" id="content0">
                    <div>
                        <div class="colleft">
                            <?php
                            $this->renderPartial('//layouts/nabar_home');
                            ?>
                            <div style="clear: both"></div>
                        </div>

                        <div class="colright" style="margin: 0px">

                            <?php
                            $this->renderPartial('//site/slider');
                            ?>

                            <div style="clear: both"></div>
                        </div>

                    </div>

                    <div  style="clear: both"></div>
                    <div id="to"></div>
                </div>
            </div>
            <div class="Colum3">
                <?php
                if ($flag > 1) {
                    ?>
                    <ul id="mycarousel1" class="jcarousel-skin-chacha">
                        <?php echo $right; ?>

                    </ul>
                    <?php
                }
                ?>
            </div>
            <div class="clear"></div>
            <div id="content1" style="margin-top: -410px">
                <?php echo $content; ?>

            </div>
            <p id="ll">l</p>

        </div>

            <?php
            $this->renderPartial('//layouts/footer');
            ?>
        </div>
    </body>
</html>
